package com.jswlw.service.biz.impl;

import com.jswlw.dao.biz.DevBillModelSetMapper;
import com.jswlw.entity.biz.DevBillModelSet;
import com.jswlw.service.biz.DevBillModelSetService;
import com.jswlw.service.helper.DevApiHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Slf4j
@Service
public class DevBillModelSetServiceImpl implements DevBillModelSetService {
    @Autowired
    DevBillModelSetMapper modelSetMapper;
    @Autowired
    DevApiHelper devApiHelper;

    @Override
    public void add(DevBillModelSet billModelSet) throws InterruptedException {
        devApiHelper.switchBillMode(billModelSet.getIcCid(),10, billModelSet.getGzms().byteValue());
        Thread.sleep(1000L);
        devApiHelper.modifyWashFixedTime(billModelSet.getIcCid(),billModelSet.getWashFixedTime().shortValue());
        Thread.sleep(1000L);
        devApiHelper.modifyWashTime(billModelSet.getIcCid(),billModelSet.getWashTime().shortValue());
        Thread.sleep(1000L);
        devApiHelper.modifyServerTime(billModelSet.getIcCid(),billModelSet.getServiceTime().shortValue());
        modelSetMapper.insert(billModelSet);
    }

    @Override
    public DevBillModelSet findLast(String icCid) {
        return modelSetMapper.findLast(icCid);
    }
}
